package com.saikuo.service;

import com.saikuo.service.constant.*;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import static springfox.documentation.builders.PathSelectors.regex;

/**
 * Created by shanchangyu on 16/10/13.
 */
@SpringBootApplication
@EnableSwagger2
@EnableAsync
@EnableConfigurationProperties({Config.class, SalipayConfig.class, LalipayConfig.class, WeiXinConfig.class, JpushConfig.class})
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Bean
    public Docket newsApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("*")
                .apiInfo(apiInfo())
                .select()
                .paths(regex("/*.*"))
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("API for 赛阔送药")
                .description("后端接口")
                .termsOfServiceUrl("未特别说明，都返回Json。")
                .contact("陈卓/单长玉")
                .license("")
                .licenseUrl("")
                .version("1.0")
                .build();
    }
}
